<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>发送post请求</button>
    <button>发送delete请求</button>
    <!-- axios是一个第三方库 -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        // 发送一个get请求 返回的是一个promise对象
        axios.get('http://localhost:3000/word').then(res=>{
            console.log(res.data);
        })
        // 发送一个post请求
        document.querySelectorAll('button')[0].onclick = function(){
            axios.post('http://localhost:3000/word',{
                content:'hello'
            })
        }
        // 发送一个delete请求
        document.querySelectorAll('button')[1].onclick = function(){
            axios.delete('http://localhost:3000/word/3')
        }
    </script>
</body>
</html>